package tu.j2ee.tasktracker.domain;

import java.util.Date;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.entity.RooJpaEntity;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaEntity
public class TaskChange {
	
	@PrePersist
	public void prePerist() {
		this.changeDate = new Date();
	}
	
    @NotNull
    private String title;

    @NotNull
    private String description;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Date estimatedDate;

    @NotNull
    @Enumerated(EnumType.STRING)
    private TaskStatus status;
    
    @ManyToOne
    private CustomUser assignedUser;
    
    @NotNull
    @ManyToOne
    private Project project;
    
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Date changeDate;
    
    @ManyToOne
    private Task task;
    
}
